package com.jinniulive.platform.module.login.fragments;


import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jinniulive.platform.R;
import com.jinniulive.platform.adapter.SubPopupAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class SubPopupFragment extends Fragment {



    public SubPopupFragment() {
        // Required empty public constructor
    }

    private RecyclerView mRecyclerView;
    private SubPopupAdapter mAdapter;
    private List<Drawable> mList;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_sub_popup, container, false);
        initView(view);
        initData();

        return view;

    }

    private void initData() {
        mList=new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Drawable drawable = getResources().getDrawable(R.mipmap.tx);
            mList.add(drawable);
        }
        mAdapter=new SubPopupAdapter(getContext(),mList);
        mRecyclerView.setAdapter(mAdapter);

    }

    private void initView(View view) {
        mRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_sub_popup_rl);
        GridLayoutManager manager=new GridLayoutManager(getContext(),2, GridLayoutManager.HORIZONTAL,false);
        mRecyclerView.setLayoutManager(manager);


    }

}
